package main;

public class RockPaperScissors {
	
	
	Result play(RPSEnum E1, RPSEnum E2)
	{
		switch(E1)
		{
		case ROCK:
			switch(E2)
			{
			case ROCK: return Result.TIE;	
			case PAPER: return Result.LOST;
			case SCISSORS: return Result.WIN;
			default: return Result.LOST;
			}
			
		case PAPER:
			switch(E2)
			{
			case ROCK: return Result.WIN;	
			case PAPER: return Result.TIE;
			case SCISSORS: return Result.LOST;
			default: return Result.LOST;
			}
			
		case SCISSORS:
			switch(E2)
			{
			case ROCK: return Result.LOST;	
			case PAPER: return Result.WIN;
			case SCISSORS: return Result.TIE;
			default: return Result.LOST;
			}
		
		default:
			return Result.LOST;
		}
		
		
	}
	
	public Result play(Player play1, Player play2)
	{
		int tour=0;
		
		for(tour=0;tour<Player.COLLEC;tour++)
		{
			Result res=play(play1.getNextMove(tour),play2.getNextMove(tour));
			if(res.equals(Result.WIN)) play1.setScore(play1.getScore()+1);
			if(res.equals(Result.LOST)) play2.setScore(play1.getScore()+1);
		}
		
		if(play1.getScore()>play2.getScore()) return Result.WIN;
		if(play1.getScore()<play2.getScore()) return Result.LOST;
		return Result.TIE;
	}

}
